### Replication Overview

This repository conducts all analysis in the main paper and appendices. `Replication 0 - Reproduce Everything.R` executes all necessary code in order. Please note, you must set your working directory at the header of this file.

NB: To reproduce the results *without running* the time-consuming models, you can set your working directory and run Replication files 4--8.

#### File Structure

- `Replication 0 - Reproduce Everything.R`: Main script to reproduce all analyses
- `run.log`: Log file produced by `Replication 0 - Reproduce Everything.R`
- `Replication 1 - Estimate Model.R`: Estimates the main IRT Loyalty Model
- `Replication 2 - Bootstrap CIs.R`: Estimates the bootstrap for the model
- `Replication 3 - Placebo Test.R`: Estimates the placebo loyalty estimates for Appendix D
- `Replication 4 - Assemble the Data.R`: Takes the estimates from the previous three steps and merge with existing datasets
- `Replication 5 - Main Paper Tables.R`: Reproduces the main paper tables
- `Replication 6 - Main Paper Figures.R`: Reproduces the main paper figures
- `Replication 7 - Appendix Tables.R`: Reproduces the appendix tables
- `Replication 8 - Appendix Figures.R`: Reproduces the appendix figures
- `Roll Call *.xlsx and *.csv`: These files contain the roll call data with speeches appended
- `Hall_members.csv`: Voteview congressmember data
- `Hall_rollcalls.csv`: Voteview congressmember votes
- `hou *.ord`: Roll calls in Keith Poole's raw .ord format
- `all_data.Rda`, `y.Rda`, `legDataTmp.Rda`, `speeches.Rda`: transformed roll call matrices to speed up the bootstrap and placebo
- `MVrollcalls.RDS`, `MVreplication.RDS`: Minozzi-Volden replication data
- `caucuses.xlsx`: caucus membership
- `FreedomCaucus.xlsx`: freedom caucus members (at creation)
- `PrimaryDefeats.xlsx`: members defeated in primary
- `VoteAgainstBoehner.csv`: members who voted against Boehner for speaker
- `pressapp.csv`: presidential approval data
- `DisposableIncome.csv`: household disposable income
- `ChallengerData_1990on.csv`: Jacobson quality challenger data
- `cFinalAllCons.csv`: Charles Stewart's committee membership data
- `Table *.txt`: output tables (produced by Replication files 5 and 7 above)
- `Figure *.pdf`: output figures (produced by Replication files 6 and 8 above)

#### Software and Environment

- R 4.3.1 with packages: mvtnorm, truncnorm, wnominate, ggplot2, tidyr, dplyr, reshape2, emIRT, doParallel,
foreach, rio, RcppEigen, doRNG, doFuture, data.table, Matrix, future.apply, plyr, fields, texreg, lme4, xtable,
GGally, stargzer, and foreign
- OS: x86_64-conda-linux-gnu
- Runtime: Less than 5 minutes (if starting from Replication 4 above) or approximately 8.5 hours (if re-executing all record linkage procedures)
- Resources: 28 CPU cores, 105GB RAM, 0 GPU cores 

